package com.zbkj.crmeb.enums;

import java.util.Objects;

import com.baomidou.mybatisplus.core.enums.IEnum;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

/**
 * 配送方式 1=一件代发 ，2=转运打包
 */
public enum WineryShippingTypeEnum implements IEnum<Integer> {

	/**
	 * 一件代发
	 */
    DROP_SHIPPING(1, "一件代发"),

	/**
	 * 转运打包
	 */
    PACKAGE(2, "转运打包"),

    ;

    private final Integer code;
    private final String msg;

    WineryShippingTypeEnum(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Integer getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    @JsonCreator
    public static WineryShippingTypeEnum valueOf(Integer code) {
        for (WineryShippingTypeEnum value : values()) {
            if (code.equals(value.getCode())) {
                return value;
            }
        }
        return null;
    }

    @Override
    @JsonValue
    public Integer getValue() {
        return code;
    }

    public static WineryShippingTypeEnum getEnumByCode(Integer code) {
        for (WineryShippingTypeEnum value : values()) {
            if (Objects.equals(value.getCode(), code)) {
                return value;
            }
        }
        return null;
    }

    public static String getMsgByCode(Integer code) {
        for (WineryShippingTypeEnum value : values()) {
            if (Objects.equals(value.getCode(), code)) {
                return value.msg;
            }
        }
        return null;
    }
}

